import request from "@/utils/request";

//请求用户列表
export const reqUserList = (page = 1, limit = 5, username = "") => {
  return request.get(`/acl/user/${page}/${limit}`, {
    params: {
      username,
    },
  });
};

//新增or修改
export const reqAddOrEdit = (formData) => {
  if (formData.id) {
    return request.put(`/acl/user/update`, formData);
  } else {
    return request.post(`/acl/user/save`, formData);
  }
};

//删除用户
export const reqDelUser = (id) => {
  return request.delete(`/acl/user/remove/${id}`);
};

//批量删除用户
export const reqBatchDelUser = (idList) => {
  return request.post(`/acl/user/batchRemove`, idList);
};

//根据userid获取角色
export const reqRoleByUserId = (userId) => {
  return request.get(`/acl/user/toAssign/${userId}`);
};

//根据用户分配角色
export const reqAssignRoleByUser = (userId, roleId) => {
  return request.post(`/acl/user/doAssign`, null, {
    params: {
      userId,
      roleId,
    },
  });
};
